package com.panda.cn.controller.ct;

import com.panda.cn.config.aspect.OperLog;
import com.panda.cn.config.aspect.OperLogType;
import com.panda.cn.entity.ct.CtRoleMenuEntity;
import com.panda.cn.service.ct.CtRoleMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/ct/rolemenucon")
public class CtRoleMenuController {
    
    @Resource
    private CtRoleMenuService ctRoleMenuService;
    
    /**
     * 根据角色查询菜单
     * @param roleCode
     * @return
     */
    @OperLog(operModul = "角色绑定菜单模块", operType = OperLogType._SEARCH, operDesc = "查询角色下所有菜单列表")
    @RequestMapping(value = "/findMenuCodes", method = RequestMethod.GET)
    public List findMenuCodes(String roleCode) {
        return ctRoleMenuService.findMenuCodes(roleCode);
    }
    
    /**
     * 更新角色下的菜单
     * @param params
     */
    @OperLog(operModul = "角色绑定菜单模块", operType = OperLogType._SEARCH, operDesc = "更新角色下菜单编码")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public void findRiverCodes(@RequestBody CtRoleMenuEntity params) {
        ctRoleMenuService.update(params);
    }
    
}
